const arr = [
  {
    id: 1,
    name: '部门A',
    children: [
      {
        id: 11,
        name: '部门A-1',
        children: []
      },
      {
        id: 12,
        name: '部门A-2',
        children: []
      }
    ]
  }
]

function mockSourceData(max, name, id) {
  if (max ===0) return  []
  const letterMap = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
  const maxData = Math.floor(Math.random() * 7)
  id||= 0;
  name ||= `部门-${letterMap[maxData]}`
  function createObj(index) {
    return {
      id: id++,
      name: `${name}-${index}`,
      children: mockSourceData(max - 1, `${name}-${index}`, id)
    }
  }
  return Array(maxData).fill(undefined).map((item, index) => {
      return createObj(index + 1)
  })
}

console.log(mockSourceData(6))
